package cn.zyl.demo.undertow;

import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.server.handlers.resource.PathResourceManager;

import java.io.File;

/**
 * UndertowFileServer类说明: undertow文件服务器
 *
 * @author z.y.l
 * @version v1.0
 * @date 2020-09-02
 */
public class UndertowFileServer {
    public static void main(String[] args) {
        //当前项目所在盘符
        File file = new File("/");
        //端口8088
        Undertow server = Undertow.builder().addHttpListener(8088, "localhost")
                .setHandler(Handlers.resource(new PathResourceManager(file.toPath(), 100)).setDirectoryListingEnabled(true))
                .build();
        //启动文件服务器
        server.start();
        System.out.println("文件服务器--启动---");
    }
}
